﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MicropleSoft.WmsApp.Library.Common;
using MicropleSoft.WmsApp.Library.Security;
using MicropleSoft.WmsApp.Library.ServiceFacade;

namespace MicropleSoft.WmsApp.Library.Factory
{
    public partial class DomainObjectFactory
    {
        public static string DefaultModelIdName = "请修改";
        public static WmsUser CreateWmsUser()
        {
            var wmsUser = new WmsUser
            {
                UserId = DefaultModelIdName,
                Passwd = Constant.YesChar,
                UserState = Constant.YesChar,
                IsDomainUser = Constant.YesChar,
                IsActive = Constant.YesChar,
                IsLocked = Constant.YesChar,
                UserStatus = Constant.YesInt,
                IsWhUser = Constant.YesChar,
                SystemCreated = Constant.YesChar,
                DomainObjectState = DomainEntityState.Added
            };
            wmsUser.AfterQueryFromServer();
            return wmsUser;
        }

        #region 作废
        public static Customer CreateCustomer()
        {
            var customer = new Customer()
            {
                WhId = UserSession.CurrentWhId,
                CustomerId = DefaultModelIdName,
                IsActive = Constant.YesChar,
                DomainObjectState = DomainEntityState.Added
            };
            customer.AfterQueryFromServer();
            return customer;
        }

        public static Vendor CreateVendor()
        {
            var vendor = new Vendor()
            {
                WhId = UserSession.CurrentWhId,
                VendorId = DefaultModelIdName,
                IsActive = Constant.YesChar,
                DomainObjectState = DomainEntityState.Added
            };
            vendor.AfterQueryFromServer();
            return vendor;
        }

        public static Owner CreateOwner()
        {
            var owner = new Owner()
            {
                WhId = UserSession.CurrentWhId,
                OwnerId = DefaultModelIdName,
                IsActive = Constant.YesChar,
                DomainObjectState = DomainEntityState.Added
            };
            owner.AfterQueryFromServer();
            return owner;
        }

        public static Carrier CreateCarrier()
        {
            var carrier = new Carrier()
            {
                WhId = UserSession.CurrentWhId,
                CarrierId = DefaultModelIdName,
                IsActive = Constant.YesChar,
                DomainObjectState = DomainEntityState.Added
            };
            carrier.AfterQueryFromServer();
            return carrier;
        }

        public static BillingEntity CreateBillingEntity()
        {
            var billingEntity = new BillingEntity()
            {
                WhId = UserSession.CurrentWhId,
                BillingEntityId = DefaultModelIdName,
                IsActive = Constant.YesChar,
                DomainObjectState = DomainEntityState.Added
            };
            billingEntity.AfterQueryFromServer();
            return billingEntity;
        }
        #endregion

        public static Pack CreatePack()
        {
            var pack = new Pack();
            //all notnull objects need initlized default value
            pack.PackUom1 = Constant.YesChar;
            pack.Qty = 0;
            pack.LengthUom1 = 0;
            pack.WidthUom1 = 0;
            pack.HeightUom1 = 0;
            pack.CubeUom1 = 0;
            pack.PackUom2 = Constant.YesChar;
            pack.InnerPack = 0;
            pack.LengthUom2 = 0;
            pack.WidthUom2 = 0;
            pack.HeightUom2 = 0;
            pack.CubeUom2 = 0;
            pack.PackUom3 = Constant.YesChar;
            pack.CaseCnt = 0;
            pack.LengthUom3 = 0;
            pack.WidthUom3 = 0;
            pack.HeightUom3 = 0;
            pack.CubeUom3 = 0;
            pack.PackUom4 = Constant.YesChar;
            pack.Pallet = 0;
            pack.LengthUom4 = 0;
            pack.WidthUom4 = 0;
            pack.HeightUom4 = 0;
            pack.CubeUom4 = 0;
            pack.PalletWoodLength = 0;
            pack.PalletWoodWidth = 0;
            pack.PalletWoodHeight = 0;
            pack.PalletTi = 0;
            pack.PalletHi = 0;
            pack.PackUom5 = Constant.YesChar;
            pack.Cube = 0;
            pack.PackUom6 = Constant.YesChar;
            pack.GrossWgt = 0;
            pack.PackUom7 = Constant.YesChar;
            pack.NetWgt = 0;
            pack.PackUom8 = Constant.YesChar;
            pack.OtherUnit1 = 0;
            pack.LengthUom8 = 0;
            pack.WidthUom8 = 0;
            pack.HeightUom8 = 0;
            pack.PackUom9 = Constant.YesChar;
            pack.OtherUnit2 = 0;
            pack.LengthUom9 = 0;
            pack.WidthUom9 = 0;
            pack.HeightUom9 = 0;
            pack.IsCartonizeUom1 = Constant.YesChar;
            pack.IsCartonizeUom2 = Constant.YesChar;
            pack.IsCartonizeUom3 = Constant.YesChar;
            pack.IsCartonizeUom4 = Constant.YesChar;
            pack.IsCartonizeUom8 = Constant.YesChar;
            pack.IsCartonizeUom9 = Constant.YesChar;
            pack.IsReplenishUom1 = Constant.YesChar;
            pack.IsReplenishUom2 = Constant.YesChar;
            pack.IsReplenishUom3 = Constant.YesChar;
            pack.IsReplenishUom4 = Constant.YesChar;
            pack.IsReplenishUom8 = Constant.YesChar;
            pack.IsReplenishUom9 = Constant.YesChar;
            pack.IsInLabelUom1 = Constant.YesChar;
            pack.IsInLabelUom2 = Constant.YesChar;
            pack.IsInLabelUom3 = Constant.YesChar;
            pack.IsInLabelUom4 = Constant.YesChar;
            pack.IsInLabelUom8 = Constant.YesChar;
            pack.IsInLabelUom9 = Constant.YesChar;
            pack.IsOutLabelUom1 = Constant.YesChar;
            pack.IsOutLabelUom2 = Constant.YesChar;
            pack.IsOutLabelUom3 = Constant.YesChar;
            pack.IsOutLabelUom4 = Constant.YesChar;
            pack.IsOutLabelUom8 = Constant.YesChar;
            pack.IsOutLabelUom9 = Constant.YesChar;
            pack.IsActive = Constant.YesChar;
            pack.SystemCreated = Constant.YesChar;
            pack.DomainObjectState = DomainEntityState.Added;
            pack.AfterQueryFromServer();
            return pack;
        }

        //public static Uom CreateUom()

        //{
        //    var uom = new Uom();
        //    uom.IsActive = Constant.YesChar;
        //    uom.SystemCreated = Constant.YesChar;
        //    uom.UomId = DefaultModelIdName;
        //    uom.DomainObjectState = DomainEntityState.Added;
        //    uom.AfterQueryFromServer();
        //    return uom;
        //}

        public static PurchaseOrder CreatePurchaseOrder()
        {
            var purchaseOrder = new PurchaseOrder
                                    {
                                        PoGroup = "",
                                        WhId = UserSession.CurrentWhId,
                                        Status = "1",   //<add Index="0" Code="1"   Name="新建"  />
                                        OwnerId = "",
                                        VendorId = "",
                                        IsActive = Constant.YesChar
                                    };
            purchaseOrder.AfterQueryFromServer();
            return purchaseOrder;
        }

        public static PurchaseOrderDetail CreatePurchaseOrderDetail()
        {
            var purchaseOrderDetail = new PurchaseOrderDetail
                                          {
                                              LineId = 1,
                                              Status = Constant.YesChar,
                                              WhId = UserSession.CurrentWhId,
                                              OwnerId = "",
                                              ReceivedQty = 0,
                                              PackId = "",
                                              TotalGrossWeight = 0,
                                              TotalCube = 0,
                                              TotalNetWeight = 0,
                                              TotalPrice = 0,
                                              QcAutoAdjust = Constant.YesChar,
                                              QcRequired = Constant.YesChar
                                          };
            purchaseOrderDetail.AfterQueryFromServer();
            return purchaseOrderDetail;
        }
    }
}
